<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>edit</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/amazeui.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/app.css">
<link
	href="${pageContext.request.contextPath}/style/css/bootstrap.min.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath}/style/layui/css/layui.css"
	rel="stylesheet">
<script src="${pageContext.request.contextPath}/style/js/jquery.min.js"></script>
<script
	src="${pageContext.request.contextPath}/style/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/style/js/amazeui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/style/layui/layui.js"></script>

</head>

<body>
	<form id="form" class="layui-form" action="#">
		<input type="hidden" name="landId" value="${land.landId }" /> <br>
		<div class="layui-form-item">
			<label class="layui-form-label">茶园名</label>
			<div class="layui-input-block">
				<input type="text" value="${land.landName }" name="landName"
					style="width:300px" required lay-verify="required"
					placeholder="请输入茶园名" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">地址</label>
			<div class="layui-input-block">
				<input type="text" value="${land.landSite }" name="landSite"
					style=" width:300px" required lay-verify="required"
					placeholder="请输入地址" autocomplete="off" class="layui-input">
			</div>

		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">品种</label>
			<div class="layui-input-block">
				<input type="text" value="${land.landVariety }" name="landVariety"
					style="width:300px" required lay-verify="required"
					placeholder="请输入品种" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">面积</label>
			<div class="layui-input-block">
				<input type="text" value="${land.landArea }" name="landArea"
					style="width:300px" required lay-verify="required"
					placeholder="请输入茶园面积" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-block" style="width:300px">
				<select name="landState" lay-verify="required">
					<option value="1">正常</option>
					<option value="0">关闭</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">管理员</label>
			<div class="layui-input-block" style="width:300px">
				<select name="landFunctionary" lay-verify="required">
					<c:forEach items="${userlist }" var="user">
						<option value="${user.userId }">${user.userName }</option>
					</c:forEach>

				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">产期</label>
			<div class="layui-inline" style="left:30px;width:250px">
				<input type="text" value="${land.landTime }" name="landTime"
					style="width:200px" required lay-verify="required|number"
					placeholder="请输入产期" autocomplete="off" class="layui-input">
			</div>
			<div class="layui-inline" style="left:-15px;width:5%">
				<label>月</label>

			</div>
		</div>
		<br>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button lay-submit class="btn btn-primary" lay-filter="go" id="sub">确定</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>

	</form>
</body>
<script type="text/javascript">
	$(document).ready(
			function() {
				 $("[name='landState'] option[value='${land.landState }']").attr("selected","true");
				 $("[name='landFunctionary'] option[value='${land.landFunctionary }']").attr("selected","true");

				//form.render();
			});
	layui.use('form', function() {
		var form = layui.form;

		form.on('submit(go)', function(data) {
			addproc();
			return false;
		});
		function addproc() {
			$.ajax({
				type : "POST",
				url : "${pageContext.request.contextPath}/land/editproc",
				data : $("#form").serialize(),
				dataType : "text",
				success : function(res) {
					if (res == "success") {
						layui.use('layer',
								function() {
									var layer = layui.layer;
									var index = parent.layer
											.getFrameIndex(window.name);
									layer.alert('数据修改成功', {
										skin : 'layui-layer-molv' //样式类名
										,
										closeBtn : 0
									}, function() {
										parent.layer.close(index);
									});
								});
					} else {
						alert("数据修改失败");
					}
				},
				error : function() {
					alert("error");
				}

			});
		}

	});
</script>
 
</html>
